package demo1102.demo03;

import java.util.concurrent.*;

/**
 * @author JYH
 * @version 1.0
 * @date 2022/11/2 10:32
 */
public class TestCallable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        Future<Integer> submit = executorService.submit(new MyCallable());

        executorService.shutdown();
        System.out.println(submit.get());
    }
}
class MyCallable implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        Integer sum=0;
        for (int i = 1; i <=100; i++) {
            sum+=i;
        }
        return sum;
    }
}